package com.bjbn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bjbn.entity.Organize;
import com.bjbn.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;


@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Insert("INSERT INTO base_user(f_id, f_account, f_real_name,  f_head_icon, f_gender,  f_mobile_phone, f_tele_phone,  f_email,   f_password, f_secretkey,   f_is_administrator,  f_organize_id, f_position_id, f_enabled_mark, f_sort_code, f_creator_time, f_creator_user_id, f_last_modify_time, f_last_modify_user_id,  f_tenant_id,  f_rank, f_standing, f_app_standing) " +
            "VALUES(#{user.id}, #{user.account}, #{user.realName}, #{user.headIcon}, #{user.gender}, #{user.mobilePhone},#{user.telePhone},#{user.email},#{user.password},#{user.secretkey},#{user.isAdministrator},#{user.organizeId},#{user.positionId},#{user.enabledMark},#{user.sortCode},#{user.creatorTime},#{user.creatorUserId},#{user.lastModifyTime},#{user.lastModifyUserId},#{user.tenantId},#{user.rank},#{user.standing},#{user.appStanding}) " +
            "ON CONFLICT (f_id,f_tenant_id) DO UPDATE SET " +
            "	f_account = EXCLUDED.f_account ," +
            "	f_real_name = EXCLUDED.f_real_name ," +
            "	f_head_icon = EXCLUDED.f_head_icon ," +
            "	f_gender = EXCLUDED.f_gender ," +
            "	f_mobile_phone = EXCLUDED.f_mobile_phone ," +
            "	f_tele_phone = EXCLUDED.f_tele_phone ," +
            "	f_email = EXCLUDED.f_email ," +
            "	f_is_administrator = EXCLUDED.f_is_administrator ," +
            "	f_organize_id = EXCLUDED.f_organize_id ," +
            "	f_position_id = EXCLUDED.f_position_id ," +
            "	f_enabled_mark = EXCLUDED.f_enabled_mark ," +
            "	f_sort_code = EXCLUDED.f_sort_code ," +
            "	f_last_modify_time = EXCLUDED.f_last_modify_time ," +
            "	f_last_modify_user_id = EXCLUDED.f_last_modify_user_id ," +
            "	f_tenant_id = EXCLUDED.f_tenant_id ," +
            "	f_rank = EXCLUDED.f_rank ," +
            "	f_standing = EXCLUDED.f_standing ," +
            "	f_app_standing = EXCLUDED.f_app_standing")
    int insertOrUpdate(@Param("user") User user);

}


